<?php
namespace BP\Sys;
require_once("BP/Difference/ContextHolderUtils.php");
require_once("BP/Tools/AesEncodeUtil.php");
require_once("BP/Tools/Cryptos.php");
require_once("javax/servlet/http/HttpServletRequest.php");
class Glo {
	protected static $Htable_BuessUnit;	// Hashtable
	protected static $Htable_FormFEE;	// Hashtable
	protected static $Htable_FormFEEDtl;	// Hashtable
	public static $Plant;	// String
	public static function __staticinit() { // static class members
		self::$Htable_BuessUnit = NULL;
		self::$Htable_FormFEE = NULL;
		self::$Htable_FormFEEDtl = NULL;
		self::$Plant = "CCFlow";
	}
	public static function GenerRealType ($attrs, $key, $val) // [Attrs attrs, String key, Object val]
	{
		$attr = $attrs->GetAttrByKey($key);
		switch ($attr->getMyDataType()) {
			case $DataType->AppString:
			case $DataType->AppDateTime:
			case $DataType->AppDate:
				$val = $val;
				break;
			case $DataType->AppInt:
			case $DataType->AppBoolean:
				$val = $Integer->parseInt($val);
				break;
			case $DataType->AppFloat:
				$val = $Float->parseFloat($val);
				break;
			case $DataType->AppDouble:
				$val = $Integer->parseInt($val);
				break;
			case $DataType->AppMoney:
				$val = $BigDecimal->valueOf($Double->parseDouble($val));
				break;
			default:
				throw new \RuntimeException();
		}
		return $val;
	}
	public static function GetBuessUnitEntityByEnName ($enName) // [String enName]
	{
		if (((self::$Htable_BuessUnit == NULL) || self::$Htable_BuessUnit->isEmpty()))
		{
			self::$Htable_BuessUnit = new Hashtable();
			$al = $BP->En->ClassFactory->GetObjects("BP.Sys.BuessUnitBase");
			foreach ($al as $en) 			{
				self::$Htable_BuessUnit->put($en, $en);
			}
		}
		$myen = ( (self::$Htable_BuessUnit->get($enName) instanceof BuessUnitBase) ? self::$Htable_BuessUnit->get($enName) : NULL );
		if (($myen == NULL))
		{
			Log->DefaultLogWriteLineError((("@根据类名称获取业务单元实例出现错�?:" . $enName) . ",没有找到该类的实�?."));
			return NULL;
		}
		return $myen;
	}
	public static function GetBuessUnitEntityStringByFlowMark ($flowMark, $flowNo) // [String flowMark, String flowNo]
	{
		$en = Glo::GetBuessUnitEntityByFlowMark($flowMark, $flowNo);
		if (($en == NULL))
		{
			return "";
		}
		return $en;
	}
	public static function GetBuessUnitEntityByFlowMark ($flowMark, $flowNo) // [String flowMark, String flowNo]
	{
		if (((self::$Htable_BuessUnit == NULL) || self::$Htable_BuessUnit->isEmpty()))
		{
			self::$Htable_BuessUnit = new Hashtable();
			$al = $BP->En->ClassFactory->GetObjects("BP.Sys.BuessUnitBase");
			self::$Htable_BuessUnit->clear();
			foreach ($al as $en) 			{
				self::$Htable_BuessUnit->put($en, $en);
			}
		}
		foreach (self::$Htable_BuessUnit->keySet() as $key) 		{
			$fee = ( (self::$Htable_BuessUnit->get($key) instanceof BuessUnitBase) ? self::$Htable_BuessUnit->get($key) : NULL );
			if (($fee->equals($flowMark) || ($fee->contains((("," . $flowNo) . ",")) ==  TRUE )))
			{
				return $fee;
			}
		}
		return NULL;
	}
	public static function GetFormEventBaseByEnName ($enName) // [String enName]
	{
		if ((self::$Htable_FormFEE == NULL))
		{
			self::$Htable_FormFEE = new Hashtable();
			$al = $BP->En->ClassFactory->GetObjects("BP.Sys.FormEventBase");
			self::$Htable_FormFEE->clear();
			foreach ($al as $en) 			{
				self::$Htable_FormFEE->put($en->getFormMark(), $en);
			}
		}
		foreach (self::$Htable_FormFEE->keySet() as $keyObj) 		{
			$fee = ( (self::$Htable_FormFEE->get($keyObj) instanceof FormEventBase) ? self::$Htable_FormFEE->get($keyObj) : NULL );
			if (($keyObj != NULL))
			{
				$key = $keyObj;
				if ($key->contains(","))
				{
					if ((($key->indexOf(($enName . ",")) >= 0) || ($key->length() == (($key->indexOf(("," . $enName)) + $enName->length()) + 1))))
					{
						return $fee;
					}
				}
				if ($enName->equals($key))
				{
					return $fee;
				}
			}
		}
		return NULL;
	}
	public static function GetFormDtlEventBaseByEnName ($dtlEnName) // [String dtlEnName]
	{
		if (((self::$Htable_FormFEEDtl == NULL) || self::$Htable_FormFEEDtl->isEmpty()))
		{
			self::$Htable_FormFEEDtl = new Hashtable();
			$al = $BP->En->ClassFactory->GetObjects("BP.Sys.FormEventBaseDtl");
			self::$Htable_FormFEEDtl->clear();
			foreach ($al as $en) 			{
				self::$Htable_FormFEEDtl->put($en->getFormDtlMark(), $en);
			}
		}
		foreach (self::$Htable_FormFEEDtl->keySet() as $key) 		{
			$fee = ( (self::$Htable_FormFEEDtl->get($key) instanceof FormEventBaseDtl) ? self::$Htable_FormFEEDtl->get($key) : NULL );
			if ((($fee->getFormDtlMark()->indexOf($dtlEnName) >= 0) || $fee->getFormDtlMark()->equals($dtlEnName)))
			{
				return $fee;
			}
		}
		return NULL;
	}
	public static function getDeptsVersion () 
	{
		$en = GloVar::constructor__();
		$en->setNo("DeptsVersion");
		if (($en->RetrieveFromDBSources() == 0))
		{
			$en->setName("部门版本�?");
			$en->setVal(DataType->getCurrentDataTime());
			$en->setGroupKey("Glo");
			$en->Insert();
		}
		return $en->getVal();
	}
	public static function getDeptsCount () 
	{
		returnDBAccess->RunSQLReturnValInt("SELECT COUNT(No) as Num FROM Port_Dept");
	}
	public static function getEmpsCount () 
	{
		returnDBAccess->RunSQLReturnValInt("SELECT COUNT(a.No) as Num FROM Port_Emp a, Port_Dept b WHERE A.FK_Dept=B.No AND A.No NOT IN ('admin','Guest')");
	}
	public static function getUsersVersion () 
	{
		$en = GloVar::constructor__();
		$en->setNo("UsersVersion");
		if (($en->RetrieveFromDBSources() == 0))
		{
			$en->setName("人员版本�?");
			$en->setVal(DataType->getCurrentDataTime());
			$en->setGroupKey("Glo");
			$en->Insert();
		}
		return $en->getVal();
	}
	public static function WriteLineInfo ($msg) // [String msg]
	{
		Log->DefaultLogWriteLineInfo($msg);
	}
	public static function WriteLineWarning ($msg) // [String msg]
	{
		Log->DefaultLogWriteLineWarning($msg);
	}
	public static function WriteLineError ($msg) // [String msg]
	{
		Log->DefaultLogWriteLineError($msg);
	}
	public static function WriteUserLog_String_String_String_String ($logType, $empNo, $msg, $ip) // [String logType, String empNo, String msg, String ip]
	{
		$ul = UserLog::constructor__();
		$ul->setMyPK(DBAccess->GenerGUID());
		$ul->setFK_Emp($empNo);
		$ul->setLogFlag($logType);
		$ul->setDocs($msg);
		$ul->setIP($ip);
		$ul->setRDT($DataType->getCurrentDataTime());
		$ul->Insert();
	}
	public static function WriteUserLog_String_String_String ($logType, $empNo, $msg) // [String logType, String empNo, String msg]
	{
		return ;
	}
	public static function getQueryStringKeys () 
	{
		$requestKeys = [];// 
		if ((Glo::getRequest() != NULL))
		{
			$enu = Glo::getRequest()->getParameterNames();
			while ($enu->hasMoreElements()) 
			{
				$key = $enu->nextElement();
				$requestKeys->add($key);
			}
		}
		return $requestKeys;
	}
	public static function getRequest () 
	{
		return $ContextHolderUtils->getRequest();
	}
	public static function SendMessageToCCIM ($fromEmpNo, $sendToEmpNo, $msg, $now) // [String fromEmpNo, String sendToEmpNo, String msg, String now]
	{
		return ;
	}
	public static function GenerFriendlyAlertHtmlInfo ($alertInfo) // [String alertInfo]
	{
		return $alertInfo;
	}
	public static function File_JiaMi ($fileFullPath, $toFileFullPath) // [String fileFullPath, String toFileFullPath]
	{
		$AesEncodeUtil->encryptFile($fileFullPath, $toFileFullPath);
	}
	public static function File_JieMi ($fileFullPath, $toFileFullPath) // [String fileFullPath, String toFileFullPath]
	{
		$AesEncodeUtil->decryptFile($fileFullPath, $toFileFullPath);
	}
	public static function String_JieMi ($str) // [String str]
	{
		if (SystemConfig::getCustomerNo()->equals("BWDA"))
			return $Cryptos->aesDecrypt($str);
		return $str;
	}
	public static function String_JieMi_FTP ($str) // [String str]
	{
		if (SystemConfig::getCustomerNo()->equals("BWDA"))
			return $Cryptos->aesDecrypt($str);
		return $str;
	}
}
Glo::__staticinit(); // initialize static vars for this class on load
?>
